home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / snpd1292.zip / SCROLL.C < prev    next >
C/C++ Source or Header  |  1992-12-26  |  2KB  |  83 lines

  1. /*--------------------------[ scroll ]--------------------------*/
  2. /*      Scroll the active page up or down a number of lines     */
  3. /*              Public domain code by Jeff Dunlop:              */
  4. /*--------------------------------------------------------------*/
  5. /* input:                                                       */
  6. /*      dx = direction                                          */
  7. /*      num_lines = number of lines to scroll, 0 = clear coords */
  8. /*      attr = attribute of blank line(s)                       */
  9. /*      y1, x1, y2, x2 = corner coordinates of scroll window    */
  10. /* local:                                                       */
  11. /*      regs = register union for ISR                           */
  12. /*--------------------------------------------------------------*/
  13.  
  14. #include <dos.h>
  15.  
  16. #define SCROLL_UP 0
  17. #define SCROLL_DN 1
  18.  
  19. void scroll(int direction,
  20.             int num_lines,
  21.             int vattrib,
  22.             int ulrow,
  23.             int ulcomumn,
  24.             int lrrow,
  25.             int lrcolumn)
  26. {
  27.       union REGS regs;
  28.  
  29.       /*
  30.             BH = attribute to be used on blank line
  31.             CH = row of upper left corner of scroll window
  32.             CL = column of upper left corner of scroll window
  33.             DH = row of lower right corner of scroll window
  34.             DL = column of lower right corner of scroll window
  35.       */
  36.  
  37.       regs.h.al = (unsigned char)num_lines;
  38.       regs.h.bh = (unsigned char)vattrib;
  39.       regs.h.ch = (unsigned char)ulrow;
  40.       regs.h.cl = (unsigned char)ulcomumn;
  41.       regs.h.dh = (unsigned char)lrrow;
  42.       regs.h.dl = (unsigned char)lrcolumn;
  43.  
  44.       if (direction == SCROLL_UP)
  45.             regs.h.ah = 0x06;
  46.       else  regs.h.ah = 0x07;
  47.  
  48.       int86(0x10, ®s, ®s);
  49. }
  50.  
  51. /*
  52. **  Portable PC clear screen function
  53. **  Public domain by Bob Stout
  54. **  Uses SCRNSIZE.C functions
  55. */
  56.  
  57. #ifndef __TURBOC__
  58.  #define far _far
  59. #endif
  60.  
  61. #define Vpage (*((unsigned char far *)0x00400062))
  62.  
  63. void ClrScrn(int vattrib)
  64. {
  65.       union REGS regs;
  66.  
  67.       scroll(SCROLL_UP, 0, vattrib, 0, 0, get_screen_rows(),
  68.             get_screen_cols());
  69.       regs.h.ah = 2;                    /* Home cursor  */
  70.       regs.h.bh = Vpage;
  71.       regs.x.dx = 0;
  72.       int86(0x10, ®s, ®s);
  73. }
  74.  
  75. #ifdef TEST
  76.  
  77. void main(void)
  78. {
  79.       ClrScrn(7);
  80. }
  81.  
  82. #endif
  83.